import { get } from "@/http/http";

export function deliveryTradeInfo(value) {
    console.log(value);
    get('/data/basic/delivery').then(res => {
        console.log(res, 'res');
        const { entrustedPrice, availableUSDT } = res.data;
        entrustedInput(entrustedPrice)
        availableAreaUSDT(availableUSDT)
    })
}

function entrustedInput(value) {
    const priceInput = document.querySelector('.bbo-price-row > .futures-pro-input-container > input')
    if (priceInput) {
        priceInput.value = value.toFixed(2);

        const event = new Event("input", { bubbles: true });
        priceInput.dispatchEvent(event);
    } else {
        console.log('未找到.bbo-price-row > .futures-pro-input-container > input');

    }
}

function availableAreaUSDT(value) {
    const availableInput = document.querySelector('.dealbox > .flex-between > div > span')
    console.log(availableInput, value, 'aaaaaavaaaaaaaillllllablee');
    if (availableInput) {
        availableInput.innerText = `${value.toFixed(2)} USDT`;
        console.log(availableInput.innerText, "availableInput.innerText");
    } else {
        console.log("未找到.dealbox > .flex-between > div > span节点");
    }
}